home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / mail / thor201.lha / THOR_2.0 / thor.lha / rexx / Filedescr2Comment.br < prev    next >
Text File  |  1995-05-15  |  2KB  |  84 lines

  1. /* Filedescr2Comment.br by Troels Walsted Hansen
  2. ** $VER: Filedescr2Comment.br v1.00 (21.01.95)
  3. **
  4. ** Search for the description of a file in THOR's filedatabase and add the
  5. ** description to the file as a filecomment. The script takes one argument
  6. ** on the commandline, and that is the path to a directory. All files in
  7. ** this directory, with a matching filecomment, will be searched for in the
  8. ** filedatabase of the BBS they were downloaded from, and their comment
  9. ** will be updated.
  10. **
  11. ** Requirements:
  12. **  · at least THOR 2.0 Pre1
  13. **  · the existing filecomment should look like this:
  14. **    "<bbsname>, <cpsvalue> cps" (NComm style)
  15. **  · an existing and complete filedatabase
  16. **  · the names of the BBSes must be the same in THOR and in NComm
  17. **  · list, delete and filenote system commands in the searchpath
  18. */
  19.  
  20. parse arg dir
  21. options results
  22.  
  23. /* needs bbsread.library functions */
  24.  
  25. if ~show('p', 'BBSREAD') then
  26. do
  27.     address command
  28.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  29.         "WaitForPort BBSREAD"
  30. end
  31.  
  32. /* shouldn't assume that the dirname ends with ":" or "/" */
  33.  
  34. endchar = right(dir, 1)
  35. if(endchar ~= ":" & endchar ~= "/") then dir = dir || '/'
  36.  
  37. /* make a list of the files and their comments */
  38.  
  39. address command 'list ' || '"' || dir || '"' || ' lformat="%-30N %C" >t:TempFilelistFile'
  40.  
  41. call open(lfh,"t:TempFilelistFile", R)
  42.  
  43. do forever
  44.     str = readln(lfh)
  45.     if(str = "") then break
  46.  
  47.     filename = strip(substr(str, 1, 30), B, " ")
  48.     if(statef(dir||filename) = "DIR") then iterate
  49.  
  50.     comment = strip(substr(str, 32), B, " ")
  51.     if(comment = "" | word(comment, words(comment)) ~= "cps") then iterate
  52.  
  53.     commapos = pos(",", comment)-1
  54.     if(commapos < 1) then iterate
  55.  
  56.     bbs = substr(comment, 1, commapos)
  57.  
  58.     address(bbsread)
  59.     SEARCHBRFILE bbsname '"'bbs'"' stem SRESULT search '"'filename'"' NAME
  60.     if(rc ~= 0 | SRESULT.FILEAREA.COUNT < 1) then iterate
  61.  
  62.     READBRFILE bbsname '"'bbs'"' fareaname '"'SRESULT.FILEAREA.1'"' filenr '"'SRESULT.FILE.1.1'"' tagsstem FTAGS
  63.     if(rc ~= 0) then iterate
  64.  
  65.     newcomment = ""
  66.  
  67.     do i=1 to FTAGS.DESCRIPTION.COUNT
  68.         newcomment = newcomment || FTAGS.DESCRIPTION.i
  69.     end
  70.  
  71.     /* write the new comment */
  72.  
  73.     say 'Filename............: ' || filename
  74.     say 'Old description.....: ' || comment
  75.     say 'New description.....: ' || newcomment
  76.     say ''
  77.  
  78.     address command 'filenote ' || '"' || dir || filename || '"' || ' ' || '"' || newcomment || '"' || ' QUIET'
  79. end
  80.  
  81. call close(lfh)
  82.  
  83. address command "delete >nil: t:TempFilelistFile"
  84.